package openfidias.maker.controller

import openfidias.maker.model.Model
import openfidias.maker.format.Formatter as f
import openfidias.maker.clazz.Clazz

/**
 *
 * @author atila
 */
class Controller extends Clazz {

   Model model

   /**
    * Create a singleton pattern and return
    */
   String singleton() {
      "${f.tab}private ${_class.capitalize()} {"
      .plus("${f.rt}}${f.ret2}")
      
      .plus("${f.tab}public static ${_class.capitalize()} getInstance() {")
      .plus("${f.rt2}")
      .plus("return ${_class.capitalize()}Holder.INSTANCE;")
      .plus("${f.rt}}${f.ret2}")

      .plus("${f.tab}private static class ${_class.capitalize()}Holder {")
      .plus("${f.rt2}")
      .plus("private static final ${_class.capitalize()} INSTANCE = new ${_class.capitalize()}();")
      .plus("${f.rt}}${f.ret2}")
   }
}

